package com.share.hystrix;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

/**
 * author:caifan
 * date:2019/7/13
 */
public class FailureCommand extends HystrixCommand<String> {
    private final String name;

    public FailureCommand(String name) {
        super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"));
        this.name = name;
    }

    @Override
    public String run() {
        throw new RuntimeException("this command always failure");
    }

    @Override
    public String getFallback() {
        return "Hello Failure : " + name;
    }
}
